define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/spelldetail/index' + location.search,
                    add_url: 'order/spelldetail/add',
                    edit_url: 'order/spelldetail/edit',
                    del_url: 'order/spelldetail/del',
                    multi_url: 'order/spelldetail/multi',
                    table: 'spell_detail',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'uid', title: __('Uid')},
                        // {field: 'orderId', title: __('Orderid')},
                        {field: 'goodsId', title: '商品ID'},
                        {field: 'skuId', title: 'SKUID'},
                        {field: 'goodsName', title: '商品名'},
                        {field: 'skuName', title: __('Skuname')},
                        {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'price', title: '价格', operate:'BETWEEN'},
                        {field: 'quantity', title: '数量'},
                        {field: 'quantity', title: ' 购买链接',formatter: function (value,row) {
                            return "<a class='btn btn-xl btn-info' target='_blank' href='https://detail.tmall.com/item.htm?id=" + row.goodsId + "' title='跳转购买'>" + '跳转购买' + "</a>";

            }},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        // add: function () {
        //     Controller.api.bindevent();
        // },
        // edit: function () {
        //     Controller.api.bindevent();
        // },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});